package com.gkt.ec.cms.activity.model.domain;

import com.gkt.ec.commons.shared.commons.entity.DataEntity;
import com.gkt.ec.commons.shared.commons.entity.LongId;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Huzl
 * @version 1.0.0
 */
public class MarketActivityEntity extends DataEntity<MarketActivityEntity, LongId> implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long id;
    private LongId uuid;
    /**
     * 是否限量，0：否，1：是
     */
    private Integer isLimited = 0;
    /**
     * 限制数量
     */
    private Integer limitNumber;
    /**
     * 活动对象，1：用户，2：车辆
     */
    private Integer activityTargetType;
    /**
     * 活动类型，1：服务，2：产品，3：礼品 多选，逗号分割
     */
    private String activityType;
    /**
     * 活动描述，限制100字
     */
    private String activityDesc;
    /**
     * 活动名称，限制20字
     */
    private String activityName;
    /**
     * 活动链接url
     */
    private String activityUrl;
    /**
     * 活动开始时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;
    /**
     * 活动结束时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;
    /**
     * 活动地点，限制50字
     */
    private String activityLocation;
    /**
     * 验证方式 1：二维码 2：数字码
     */
    private Integer verifyType;
    /**
     * 活动区域
     */
    private String activityArea;
    /**
     * 活动发送类型，1：立即发送，2：定时发送
     */
    private Integer smsSendType;
    /**
     * 定时发送时间点，精确到分钟
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date smsSendTime;
    /**
     * 短信发送任务状态 0：未发送 1：开始发送 4：发送结束
     */
    private Integer smsSendStatus;
    /**
     * 短信发送开始时间
     */
    private Timestamp smsSendBeginTime;
    /**
     * 短信发送结束时间
     */
    private Timestamp smsSendEndTime;
    /**
     * 发送短信内容
     */
    private String smsTemplate;
    private Timestamp updateTime;
    private Timestamp createTime;
    private String createUser;
    private String updateUser;
    /**
     * 是否删除 1：删除 0：正常
     */
    private Integer isDeleted;
    //客户参加活动后通知短信模板
    private String attendNotifySmsTemplate;

    /**
     * 用户输入的搜索关键字
     */
    private String searchGender;
    private String searchAge;
    private String searchMills;
    private String searchAgeLimit;
    private String searchStartTime;
    private String searchEndTime;
    private String searchVehicle;
    private String searchVehicleIds;

    //活动关联的企业列表
    private List<CompanyEntity> companyList = new ArrayList<CompanyEntity>();
    //活动企业名称
    private String companyNames;
    private String activityStatus;
    //选择的企业id
    private String companyIds;

    public String getCompanyNames() {
        List<String> companyNameList = new ArrayList<String>();
        for (CompanyEntity ce : companyList) {
            companyNameList.add(ce.getCompanyName());
        }
        if (CollectionUtils.isNotEmpty(companyNameList)) {
            companyNames = StringUtils.join(companyNameList.toArray(), ",");
        }
        return companyNames;
    }

    public void setCompanyNames(String companyNames) {
        this.companyNames = companyNames;
    }

    public void setCompanyIds(String companyIds) {
        this.companyIds = companyIds;
    }

    public String getCompanyIds() {
        List<Long> companyIdList = new ArrayList<Long>();
        for (CompanyEntity ce : companyList) {
            companyIdList.add(ce.getId());
        }
        if (CollectionUtils.isNotEmpty(companyIdList)) {
            companyIds = StringUtils.join(companyIdList.toArray(), ",");
        }

        return companyIds;
    }

    public String getSearchVehicleIds() {
        return searchVehicleIds;
    }

    public void setSearchVehicleIds(String searchVehicleIds) {
        this.searchVehicleIds = searchVehicleIds;
    }

    public String getSearchVehicle() {
        return searchVehicle;
    }

    public void setSearchVehicle(String searchVehicle) {
        this.searchVehicle = searchVehicle;
    }

    public List<CompanyEntity> getCompanyList() {
        return companyList;
    }

    public void setCompanyList(List<CompanyEntity> companyList) {
        this.companyList = companyList;
    }

    public String getSearchAgeLimit() {
        return searchAgeLimit;
    }

    public String getActivityStatus() {
        return activityStatus;
    }

    public void setActivityStatus(String activityStatus) {
        this.activityStatus = activityStatus;
    }

    public String getAttendNotifySmsTemplate() {
        return attendNotifySmsTemplate;
    }

    public void setAttendNotifySmsTemplate(String attendNotifySmsTemplate) {
        this.attendNotifySmsTemplate = attendNotifySmsTemplate;
    }

    public void setSearchAgeLimit(String searchAgeLimit) {
        this.searchAgeLimit = searchAgeLimit;
    }

    public String getSearchStartTime() {
        return searchStartTime;
    }

    public void setSearchStartTime(String searchStartTime) {
        this.searchStartTime = searchStartTime;
    }

    public String getSearchEndTime() {
        return searchEndTime;
    }

    public void setSearchEndTime(String searchEndTime) {
        this.searchEndTime = searchEndTime;
    }

    public String getSearchGender() {
        return searchGender;
    }

    public void setSearchGender(String searchGender) {
        this.searchGender = searchGender;
    }

    public String getSearchAge() {
        return searchAge;
    }

    public void setSearchAge(String searchAge) {
        this.searchAge = searchAge;
    }

    public String getSearchMills() {
        return searchMills;
    }

    public void setSearchMills(String searchMills) {
        this.searchMills = searchMills;
    }

    public Long getId() {
        return id;
    }

    public MarketActivityEntity setId(Long id) {
        this.id = id;
        setUuid(String.valueOf(id));
        return this;
    }

    @Override
    public LongId getUuid() {
        return uuid;
    }

    @Override
    public void setUuid(String uuid) {
        try {
            long theUUID = Long.parseLong(uuid);
            this.uuid = new LongId(theUUID);
        } catch (Exception e) {
            //TODO what if uuid is a string?
        }
    }

    public Integer getIsLimited() {
        return isLimited;
    }

    public MarketActivityEntity setIsLimited(Integer isLimited) {
        this.isLimited = isLimited;
        return this;
    }

    public Integer getLimitNumber() {
        return limitNumber;
    }

    public MarketActivityEntity setLimitNumber(Integer limitNumber) {
        this.limitNumber = limitNumber;
        return this;
    }

    public Integer getActivityTargetType() {
        return activityTargetType;
    }

    public MarketActivityEntity setActivityTargetType(Integer activityTargetType) {
        this.activityTargetType = activityTargetType;
        return this;
    }

    public String getActivityType() {
        return activityType;
    }

    public MarketActivityEntity setActivityType(String activityType) {
        this.activityType = activityType;
        return this;
    }

    public String getActivityDesc() {
        return activityDesc;
    }

    public MarketActivityEntity setActivityDesc(String activityDesc) {
        this.activityDesc = activityDesc;
        return this;
    }

    public String getActivityName() {
        return activityName;
    }

    public MarketActivityEntity setActivityName(String activityName) {
        this.activityName = activityName;
        return this;
    }

    public String getActivityUrl() {
        return activityUrl;
    }

    public MarketActivityEntity setActivityUrl(String activityUrl) {
        this.activityUrl = activityUrl;
        return this;
    }

    public Date getStartTime() {
        return startTime;
    }

    public MarketActivityEntity setStartTime(Date startTime) {
        this.startTime = startTime;
        return this;
    }

    public Date getEndTime() {
        return endTime;
    }

    public MarketActivityEntity setEndTime(Date endTime) {
        this.endTime = endTime;
        return this;
    }

    public String getActivityLocation() {
        return activityLocation;
    }

    public MarketActivityEntity setActivityLocation(String activityLocation) {
        this.activityLocation = activityLocation;
        return this;
    }

    public Integer getVerifyType() {
        return verifyType;
    }

    public MarketActivityEntity setVerifyType(Integer verifyType) {
        this.verifyType = verifyType;
        return this;
    }

    public String getActivityArea() {
        return activityArea;
    }

    public MarketActivityEntity setActivityArea(String activityArea) {
        this.activityArea = activityArea;
        return this;
    }

    public Integer getSmsSendType() {
        return smsSendType;
    }

    public MarketActivityEntity setSmsSendType(Integer smsSendType) {
        this.smsSendType = smsSendType;
        return this;
    }

    public Date getSmsSendTime() {
        return smsSendTime;
    }

    public MarketActivityEntity setSmsSendTime(Date smsSendTime) {
        this.smsSendTime = smsSendTime;
        return this;
    }

    public Integer getSmsSendStatus() {
        return smsSendStatus;
    }

    public MarketActivityEntity setSmsSendStatus(Integer smsSendStatus) {
        this.smsSendStatus = smsSendStatus;
        return this;
    }

    public Timestamp getSmsSendBeginTime() {
        return smsSendBeginTime;
    }

    public MarketActivityEntity setSmsSendBeginTime(Timestamp smsSendBeginTime) {
        this.smsSendBeginTime = smsSendBeginTime;
        return this;
    }

    public Timestamp getSmsSendEndTime() {
        return smsSendEndTime;
    }

    public MarketActivityEntity setSmsSendEndTime(Timestamp smsSendEndTime) {
        this.smsSendEndTime = smsSendEndTime;
        return this;
    }

    public String getSmsTemplate() {
        return smsTemplate;
    }

    public MarketActivityEntity setSmsTemplate(String smsTemplate) {
        this.smsTemplate = smsTemplate;
        return this;
    }

    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public MarketActivityEntity setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
        return this;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public MarketActivityEntity setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
        return this;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public String getUpdateUser() {
        return updateUser;
    }

    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }

    public Integer getIsDeleted() {
        return isDeleted;
    }

    public MarketActivityEntity setIsDeleted(Integer isDeleted) {
        this.isDeleted = isDeleted;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MarketActivityEntity that = (MarketActivityEntity) o;

        if (id != that.id) return false;
        if (isLimited != null ? !isLimited.equals(that.isLimited) : that.isLimited != null)
            return false;
        if (limitNumber != null ? !limitNumber.equals(that.limitNumber) : that.limitNumber != null)
            return false;
        if (activityTargetType != null ? !activityTargetType.equals(that.activityTargetType) : that.activityTargetType != null)
            return false;
        if (activityType != null ? !activityType.equals(that.activityType) : that.activityType != null)
            return false;
        if (activityDesc != null ? !activityDesc.equals(that.activityDesc) : that.activityDesc != null)
            return false;
        if (activityName != null ? !activityName.equals(that.activityName) : that.activityName != null)
            return false;
        if (activityUrl != null ? !activityUrl.equals(that.activityUrl) : that.activityUrl != null)
            return false;
        if (startTime != null ? !startTime.equals(that.startTime) : that.startTime != null)
            return false;
        if (endTime != null ? !endTime.equals(that.endTime) : that.endTime != null) return false;
        if (activityLocation != null ? !activityLocation.equals(that.activityLocation) : that.activityLocation != null)
            return false;
        if (verifyType != null ? !verifyType.equals(that.verifyType) : that.verifyType != null)
            return false;
        if (activityArea != null ? !activityArea.equals(that.activityArea) : that.activityArea != null)
            return false;
        if (smsSendType != null ? !smsSendType.equals(that.smsSendType) : that.smsSendType != null)
            return false;
        if (smsSendTime != null ? !smsSendTime.equals(that.smsSendTime) : that.smsSendTime != null)
            return false;
        if (smsSendStatus != null ? !smsSendStatus.equals(that.smsSendStatus) : that.smsSendStatus != null)
            return false;
        if (smsSendBeginTime != null ? !smsSendBeginTime.equals(that.smsSendBeginTime) : that.smsSendBeginTime != null)
            return false;
        if (smsSendEndTime != null ? !smsSendEndTime.equals(that.smsSendEndTime) : that.smsSendEndTime != null)
            return false;
        if (smsTemplate != null ? !smsTemplate.equals(that.smsTemplate) : that.smsTemplate != null)
            return false;
        if (updateTime != null ? !updateTime.equals(that.updateTime) : that.updateTime != null)
            return false;
        if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null)
            return false;
        if (createUser != null ? !createUser.equals(that.createUser) : that.createUser != null)
            return false;
        if (updateUser != null ? !updateUser.equals(that.updateUser) : that.updateUser != null)
            return false;
        if (isDeleted != null ? !isDeleted.equals(that.isDeleted) : that.isDeleted != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + (isLimited != null ? isLimited.hashCode() : 0);
        result = 31 * result + (limitNumber != null ? limitNumber.hashCode() : 0);
        result = 31 * result + (activityTargetType != null ? activityTargetType.hashCode() : 0);
        result = 31 * result + (activityType != null ? activityType.hashCode() : 0);
        result = 31 * result + (activityDesc != null ? activityDesc.hashCode() : 0);
        result = 31 * result + (activityName != null ? activityName.hashCode() : 0);
        result = 31 * result + (activityUrl != null ? activityUrl.hashCode() : 0);
        result = 31 * result + (startTime != null ? startTime.hashCode() : 0);
        result = 31 * result + (endTime != null ? endTime.hashCode() : 0);
        result = 31 * result + (activityLocation != null ? activityLocation.hashCode() : 0);
        result = 31 * result + (verifyType != null ? verifyType.hashCode() : 0);
        result = 31 * result + (activityArea != null ? activityArea.hashCode() : 0);
        result = 31 * result + (smsSendType != null ? smsSendType.hashCode() : 0);
        result = 31 * result + (smsSendTime != null ? smsSendTime.hashCode() : 0);
        result = 31 * result + (smsSendStatus != null ? smsSendStatus.hashCode() : 0);
        result = 31 * result + (smsSendBeginTime != null ? smsSendBeginTime.hashCode() : 0);
        result = 31 * result + (smsSendEndTime != null ? smsSendEndTime.hashCode() : 0);
        result = 31 * result + (smsTemplate != null ? smsTemplate.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (createUser != null ? createUser.hashCode() : 0);
        result = 31 * result + (updateUser != null ? updateUser.hashCode() : 0);
        result = 31 * result + (isDeleted != null ? isDeleted.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "MarketActivityEntity{" +
                "id=" + id +
                ", uuid=" + uuid +
                ", isLimited=" + isLimited +
                ", limitNumber=" + limitNumber +
                ", activityTargetType=" + activityTargetType +
                ", activityType='" + activityType + '\'' +
                ", activityDesc='" + activityDesc + '\'' +
                ", activityName='" + activityName + '\'' +
                ", activityUrl='" + activityUrl + '\'' +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                ", activityLocation='" + activityLocation + '\'' +
                ", verifyType=" + verifyType +
                ", activityArea='" + activityArea + '\'' +
                ", smsSendType=" + smsSendType +
                ", smsSendTime=" + smsSendTime +
                ", smsSendStatus=" + smsSendStatus +
                ", smsSendBeginTime=" + smsSendBeginTime +
                ", smsSendEndTime=" + smsSendEndTime +
                ", smsTemplate='" + smsTemplate + '\'' +
                ", updateTime=" + updateTime +
                ", createTime=" + createTime +
                ", createUser='" + createUser + '\'' +
                ", updateUser='" + updateUser + '\'' +
                ", isDeleted=" + isDeleted +
                ", attendNotifySmsTemplate='" + attendNotifySmsTemplate + '\'' +
                ", searchGender='" + searchGender + '\'' +
                ", searchAge='" + searchAge + '\'' +
                ", searchMills='" + searchMills + '\'' +
                ", searchAgeLimit='" + searchAgeLimit + '\'' +
                ", searchStartTime='" + searchStartTime + '\'' +
                ", searchEndTime='" + searchEndTime + '\'' +
                ", searchVehicle='" + searchVehicle + '\'' +
                ", searchVehicleIds='" + searchVehicleIds + '\'' +
                ", companyList=" + companyList +
                ", companyNames='" + companyNames + '\'' +
                ", activityStatus='" + activityStatus + '\'' +
                ", companyIds='" + companyIds + '\'' +
                '}';
    }
}
